﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using libDAL;
using libCommonTools.Forms;
using libCommonTools.BUS;
using libAddressBook.BUS;

namespace libAddressBook.FORMS
{
    public partial class frmContacts : Telerik.WinControls.UI.RadForm
    {
        public frmContacts()
        {
            InitializeComponent();
        }

               private string strType = string.Empty;

        private cls_DAL _DAL;
        private clsInterfaceWebsiteEmailContactFax Contacts;
        private string strCompanyID = string.Empty;

        public string getset_CompanyID
        {
            get
            {
                return strCompanyID;
            }
            set
            {
                strCompanyID = value;
            }
        }

        public cls_DAL set_DataAccess
        {
            set
            {
                _DAL = value;
            }
        }

        public string getset_Type
        {
            get
            {
                return this.strType;
            }
            set
            {
                this.strType = value;
            }
        }

        private void frmContacts_Load(object sender, EventArgs e)
        {
            try
            {
                this.Size = new Size(601, 386);
                Contacts = new clsInterfaceWebsiteEmailContactFax();
                Contacts.set_DataAccess = _DAL;
                Contacts.set_CompanyID = getset_CompanyID;
                set_DataGrid();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " frmWebsiteEmailFax_Load");
            }
        }

        private void set_DataGrid()
        {
            try
            {
                if (getset_Type != string.Empty)
                {
                    if (getset_Type == "Contacts")
                    {
                        Contacts.getset_ContactType = getset_Type;
                        Contacts.set_CompanyID = getset_CompanyID;
                        set_LoadGridRecords();
                    }

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " set_DataGrid");
            }
        }

        private void set_LoadGridRecords()
        {
            dgvContacts.DataSource = Contacts.get_ContactPerson;
            dgvContacts.Columns[0].IsVisible = false;
            dgvContacts.Columns[1].IsVisible = false;
            dgvContacts.Columns["Dfault"].ReadOnly = true;
        }

        private void cbbReFreshContacts_Click(object sender, EventArgs e)
        {
            chkDefault.Checked = false;
            rboAlter.IsChecked = false;
            rboNew.IsChecked = false;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

       
    }
}
